//
//  BidModel.swift
//  cxd4iphone
//
//  Created by hexy on 12/16/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit

class BidModel: Model {

    var money: Int = 0

    var status: String?

    var loanPurpose: String?

    var cardinalNumber: Int = 0

    var exceptTime: String?

    var remainMoney: String?

    var remainTime: String?

    var name: String?
    
    var investInfo: InvestinfoModel?
    
    var loanWindControlPicUrls: [BidPicModel]?
    
    var loanInfoPicUrls: [BidPicModel]?
    
    var listLoanInfoList: [BidDescribeModel]?

    var listWindControlList: [BidDescribeModel]?

    var progress: Int = 0

    var investTime: String?

    var id: String?

    var minInvestMoney: Int = 0

    var loanMoney: String?

    var businessType: String?

    var deadline: Int = 0

    var unit: String?

    var rate: String?

    var investMoney: Int = 0

    var userId: String?
    
    var contractUrl: String?
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        
        
        if key == "investInfo" {
            
//            xx_JsonPrint(dict: value as! [String: AnyObject])
//            xx_print(value)
            guard let v = value else { return }
            investInfo = InvestinfoModel(dict: v as! [String: AnyObject])
            
            return
        }
        
        if key == "listLoanInfoList" {
            
            let array = value as! [[String: AnyObject]]
            var arrM = [BidDescribeModel]()
            
            for dict in array {
            
                arrM.append(BidDescribeModel(dict: dict))
            }

            listLoanInfoList = arrM
            return
        }
        
        if key == "listWindControlList" {
            
            let array = value as! [[String: AnyObject]]
            var arrM = [BidDescribeModel]()
            
            for dict in array {
                
                arrM.append(BidDescribeModel(dict: dict))
            }
            
            listWindControlList = arrM
            return
        }

        
        if key == "loanWindControlPicUrls" {
            
            let array = value as! [[String: AnyObject]]
            var arrM = [BidPicModel]()
            
            for dict in array {
                
                arrM.append(BidPicModel(dict: dict))
            }
            
            loanWindControlPicUrls = arrM
            return
        }
        
        if key == "loanInfoPicUrls" {
            
            let array = value as! [[String: AnyObject]]
            var arrM = [BidPicModel]()
            
            for dict in array {
                
                arrM.append(BidPicModel(dict: dict))
            }
            
            loanInfoPicUrls = arrM
            return
        }

        
        super.setValue(value, forKey: key)
        
    }

}


class InvestinfoModel: Model {

    var nextRepayDate: Double = 0.0

    var waitingCollectMoney: String?

    var nextCollectMoney: String?

}

class BidPicModel: Model {
    
    var picUrl: String?
    
}

class BidDescribeModel: Model {

    var key: String?

    var value: String?

}


